package com.bite.java_chatroom.service;

import com.bite.java_chatroom.mapper.MessageSessionMapper;
import com.bite.java_chatroom.model.MessageSession;
import com.bite.java_chatroom.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageSessionService {
    @Autowired
    private MessageSessionMapper messageSessionMapper;

    public List<Integer> getSessionIdByUserId(Integer id) {
        return messageSessionMapper.getSessionList(id);
    }

    public List<UserInfo> getFriendsBySessionId(Integer sessionId ,Integer userSelfId) {
        return messageSessionMapper.getFriendBySessionId(sessionId,userSelfId);
    }

    public void addMessageSessionUser(Integer sessionId, Integer id) {
        messageSessionMapper.addMessageSessionUser(sessionId,id);
    }

    public void addMessageSession(MessageSession messageSession) {
        messageSessionMapper.addSession(messageSession);
    }

    public Integer getSessionIdByfriendId(Integer id, Integer friendId) {
        return messageSessionMapper.getSessionIdByfriendId(id,friendId);
    }
}
